/*
 * Manager.java
 * Created on Mar 25, 2011, 1:00:40 AM
 * 
 */


package graphicsReport;

import java.util.logging.Level;

/**
 * This is the panel that we named "report pane". It's the panel that lists all
 * report function as buttons.
 * 
 * Currently, we already got two report functions here.
 * 
 * @author  Jianwei Chris Leng
 * @since   Created on Mar 25, 2011, 1:00:40 AM
 * 
 */
public class Manager extends javax.swing.JPanel {

    /**the parameter GUI that we will use this to refresh the screen after we
     * got this report panel prepared.
     */
    protected userInterface.GUI __gui = null;

    /**the GUI component: a form that we use to */
    protected report.iaaReport.IAA __iaa = null;
    
    protected GraphicsReport_PositionIndicators pi = null;

    /** Creates new form Manager
     * 
     * @param   _gui
     *          It's the pointer which link us to current parent GUI
     */
    public Manager(userInterface.GUI _gui) {

        //
        this.__gui = _gui;

        // initlize this report panel, set location, size, etc
        initComponents();
    }



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jPanel_top = new javax.swing.JPanel();
        jPanel_left = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jPanel_center = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(240, 240, 241));
        setLayout(new java.awt.BorderLayout());

        jPanel_top.setBackground(new java.awt.Color(240, 240, 241));
        jPanel_top.setBorder(javax.swing.BorderFactory.createMatteBorder(22, 4, 1, 4, new java.awt.Color(240, 240, 241)));
        jPanel_top.setLayout(new java.awt.BorderLayout());

        jPanel_left.setBackground(new java.awt.Color(240, 240, 241));
        jPanel_left.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 10, 0, 10, new java.awt.Color(240, 240, 241)));
        jPanel_left.setLayout(new java.awt.GridBagLayout());

        jButton1.setText("Graph Reports of Position Indicators");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel_left.add(jButton1, new java.awt.GridBagConstraints());

        jButton2.setText("Annotator Performance");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        jPanel_left.add(jButton2, gridBagConstraints);

        jPanel_top.add(jPanel_left, java.awt.BorderLayout.WEST);

        jPanel_center.setBackground(new java.awt.Color(240, 240, 241));
        jPanel_center.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 5, 0, 10, new java.awt.Color(240, 240, 241)));
        jPanel_center.setLayout(new java.awt.GridLayout(2, 0, 0, 3));

        jPanel1.setBackground(new java.awt.Color(240, 240, 241));
        jPanel1.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, new java.awt.Color(0, 0, 0)));
        jPanel1.setLayout(new java.awt.BorderLayout());

        jLabel1.setText("Graph report of position indicators to multiple documents.");
        jPanel1.add(jLabel1, java.awt.BorderLayout.CENTER);

        jPanel_center.add(jPanel1);

        jPanel2.setBackground(new java.awt.Color(240, 240, 241));
        jPanel2.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, new java.awt.Color(0, 0, 0)));
        jPanel2.setLayout(new java.awt.BorderLayout());

        jLabel2.setText("Generate IAA Reports for Annotator Performance");
        jPanel2.add(jLabel2, java.awt.BorderLayout.CENTER);

        jPanel_center.add(jPanel2);

        jPanel_top.add(jPanel_center, java.awt.BorderLayout.CENTER);

        add(jPanel_top, java.awt.BorderLayout.NORTH);
    }// </editor-fold>//GEN-END:initComponents

    /***/
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        try{
            if(pi!=null)
                pi.dispose();

            pi = new GraphicsReport_PositionIndicators(__gui);
            pi.setVisible(true);

            // show log after we done
            log.LoggingToFile.log(Level.FINEST, "Loaded the GUI of the annotation"
                    + " mapping report system into current tab as a form.");

        }catch(Exception ex){
            log.LoggingToFile.log(Level.SEVERE, "Fail to load the form GUI of " +
                    "annotation mapping system into current tab.\n" +
                    "\tError Details: " + ex.toString()
                    );
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

        try{
            if( __iaa != null )
                __iaa.dispose();

            __iaa = new report.iaaReport.IAA(__gui);
            __iaa.setVisible(true);

            log.LoggingToFile.log(Level.FINEST, "Loaded the GUI of IAA report into " +
                    "current tab as a form.");

        }catch(Exception ex){

            // error log
            log.LoggingToFile.log(Level.SEVERE, "Fail to load the form GUI of " +
                    "IAA report system into current tab.\n" +
                    "\tError Details: " + ex.toString()
                    );
        }
    }//GEN-LAST:event_jButton2ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel_center;
    private javax.swing.JPanel jPanel_left;
    private javax.swing.JPanel jPanel_top;
    // End of variables declaration//GEN-END:variables

}
